package org.yellow.backend.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.yellow.backend.pojo.bill;
import org.yellow.backend.service.appointmentService;
import org.yellow.backend.service.billService;

/**
 * @author: hy
 * @create: 2024-01-01
 */
@Slf4j
@RestController
@SuppressWarnings({"all"})
@RequestMapping("/bill")
public class billController {
    @Autowired
    private billService service;
    @Autowired
    private appointmentService appointmentservice;
    @GetMapping("/{id}")
    public bill getBill(@PathVariable("id") int id){
        log.info("查看编号为"+id+"的账单");
        return service.selectBillById(id);
    }
    @GetMapping("/payNow/{id}")
    public boolean payNow(@PathVariable("id") int id){
        log.info(""+id+"号账单立即支付");

        service.payNow(id);
        appointmentservice.updateStatus(id);
        return true;
    }

    @GetMapping("/payLater/{id}")
    public boolean payLater(@PathVariable("id") int id){
        log.info(""+id+"号账单延迟支付");
        return service.payLater(id);
    }

    @GetMapping("/refund/{id}")
    public boolean refund(@PathVariable("id") int id){
        log.info(""+id+"号账单退款");
        return service.refund(id);
    }
}
